<?php
namespace library\widgets;

use idea\mvc\Widget;
use idea\saf\Conf;

/**
 * TopNav class file
 * 页面顶端导航
 * @author 宋欢 <iphper@yeah.net>
 * @version $Id: TopNav.php 1 2013-04-20 17:11:06Z huan.song $
 * @package library.widgets
 * @since 1.0
 */
class TopNav extends Widget
{
	/**
	 * 执行Widget类，输出内容
	 * @return void
	 */
	public function run()
	{	
		$urls = Conf::getAppConf('urls');
		$topNavs = Conf::getAppConf('topNavs');
		$contr = $this->getView()->controller;
		$scriptUrl = $this->getView()->script_url;
		
		$html = '';
		foreach ($topNavs as $urlName) {
			$url = $scriptUrl . $urls[$urlName]['href'];
			$html .= '<a href="' . $url . '"' . (($contr === $urlName) ? 'class="selected"' : '') . '>' 
				  . $urls[$urlName]['label'] 
				  . '</a>';
		}
		
		echo $html;
	}
}
